/*
 * @(#)ResultTypeInfo.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.config;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * 환경 파일로부터의 ResultType 정보를 넣을 모델.
 *
 * @author Web Platform Development Team
 */
public final class ResultTypeInfo {
    /**
     * 현재 객체 참조자.
     */
    private static ResultTypeInfo resultTypeInfo;

    /**
     * ResultTypeInfo 정보 저장을 위한 {@link Map}
     */
    private Map<String, String> resultTypeInfos = new HashMap<String, String>();

    /**
     * 생성자.
     */
    private ResultTypeInfo() {
    }

    /**
     * ResultTypeInfo 객체 반환.
     *
     * @return ResultTypeInfo the result type information
     */
    public static ResultTypeInfo getInstance() {
        if (resultTypeInfo == null) {
            resultTypeInfo = new ResultTypeInfo();
        }

        return resultTypeInfo;
    }

    /**
     * ResultType 정보 추가.
     *
     * @param name  the result type name
     * @param clazz the result class name
     */
    public void addResultTypeInfo(String name, String clazz) {
        resultTypeInfos.put(name, clazz);
    }

    /**
     * ResultType 정보(Class) 반환.
     *
     * @param name the result type name
     * @return String the result class name
     */
    public String getResutlTypeInfo(String name) {
        return resultTypeInfos.get(name);
    }

    /**
     * Returns <tt>true</tt> if this map contains a mapping for the specified
     * resultType of name.
     *
     * @param name the result type name
     * @return boolean the result type name exist or don't exist
     */
    public boolean containsKey(String name) {
        return resultTypeInfos.containsKey(name);
    }

    /**
     * ResultType 에 대한 {@link Entry} {@link Set} 반환.
     *
     * @return Set the result type information
     */
    public Set<Map.Entry<String, String>> getResultTypeInfos() {
        return resultTypeInfos.entrySet();
    }

    /**
     * 모든 정보 삭제
     */
    public void clear() {
        resultTypeInfos.clear();
    }
}
